package lan;

import java.util.Scanner;

public class suanriqi {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个年份：");
        int year1 = scanner.nextInt();
        System.out.println("请输入第一个月份：");
        int month1 = scanner.nextInt();
        System.out.println("请输入第一个号数：");
        int day1 = scanner.nextInt();
        System.out.println("请输入第二个年份：");
        int year2 = scanner.nextInt();
        System.out.println("请输入第二个月份：");
        int month2 = scanner.nextInt();
        System.out.println("请输入第二个号数：");
        int day2 = scanner.nextInt();
        int sum=0;
        if(year1==year2) {
            for (int i = month1; i < month2; i++) {
                sum = sum + getDaysInMonth(year1, i);
            }
        }
        else {
            for (int i = month1; i < 13; i++) {
                sum = sum + getDaysInMonth(year1, i);
            }
            for (int i = 1; i < month2; i++) {
                if (month2 == 1) break;
                sum = sum + getDaysInMonth(year2, i);
            }
            for (int i = year1 + 1; i < year2; i++) {
                sum = sum + getDaysInyear(i);
            }
        }
        sum=sum-(day1-1)+(day2-1);
        System.out.println("距离"+sum+"天");
    }
    public static int getDaysInyear(int year) {
        if (isLeapYear(year)) {
            return 366;
        } else {
            return 365;
        }
    }
    public static int getDaysInMonth(int year,int month) {
        switch (month) {
            case 1: return 31;
            case 2:if (isLeapYear(year)) {
                return 29;
            } else {
                return 28;
            }

            case 3: return 31;
            case 4: return 30;
            case 5: return 31;
            case 6: return 30;
            case 7: return 31;
            case 8: return 31;
            case 9: return 30;
            case 10: return 31;
            case 11: return 30;
            case 12: return 31;
            default: return -1;
        }
    }

    public static boolean isLeapYear(int year) {
        if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
            return true;
        } else {
            return false;
        }
    }
}

